// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 

package com.nnee.p_pr.p_c;

import android.content.*;
import android.database.Cursor;
import android.text.TextUtils;
import com.nnee.p_a.p_a.cls_g;
import com.nnee.p_g.cls_b;
import com.nnee.p_pr.p_prov.cls_a;

public class cls_i
{

    public cls_i()
    {
    }

    private static long a(Context context, String[] as, String s)
    {
        Cursor cursor = context.getContentResolver().query(cls_a.b, as, s, null, null);
        long l1 = 0L;
        if(cursor != null)
        {
            if(cursor.moveToFirst())
                l1 = cursor.getLong(0);
            cursor.close();
        }
        return l1;
    }

    public static cls_g a(Context context, String s, String s1)
    {
        cls_g g1 = null;
        if(s1 != null) {
        	Cursor cursor;
            String s2;
            String as[];
            if(s == null)
            {
                s2 = "url =?";
                as = new String[1];
                as[0] = s1;
            } else
            {
                s2 = "account = ? AND url = ?";
                as = new String[2];
                as[0] = s;
                as[1] = s1;
            }
            cursor = context.getContentResolver().query(cls_a.b, a, s2, as, g1);
            if(cursor == null)
            	 return g1;
            if(!cursor.moveToFirst())
            	 return g1;
            g1 = new cls_g();
            g1.a(cursor.getString(4));
            g1.e(cursor.getString(3));
            g1.c(cursor.getString(7));
            g1.c(cursor.getLong(6));
            g1.d(cursor.getString(5));
            g1.b(cursor.getString(8));
            g1.b(cursor.getLong(9));
            g1.a(cursor.getLong(0));
            g1.a("f".equals(cursor.getString(11)));
            if(cursor != null)
                cursor.close();
            continue; /* Loop/switch isn't completed */
            if(cursor != null)
                cursor.close();
            return g1;
        } else  return g1;
_L1:
        return g1;
_L2:
        Cursor cursor;
        String s2;
        String as[];
        if(s == null)
        {
            s2 = "url =?";
            as = new String[1];
            as[0] = s1;
        } else
        {
            s2 = "account = ? AND url = ?";
            as = new String[2];
            as[0] = s;
            as[1] = s1;
        }
        cursor = context.getContentResolver().query(a.b, a, s2, as, g1);
        if(cursor == null)
            break MISSING_BLOCK_LABEL_226;
        if(!cursor.moveToFirst())
            break MISSING_BLOCK_LABEL_226;
        g1 = new cls_g();
        g1.a(cursor.getString(4));
        g1.e(cursor.getString(3));
        g1.c(cursor.getString(7));
        g1.c(cursor.getLong(6));
        g1.d(cursor.getString(5));
        g1.b(cursor.getString(8));
        g1.b(cursor.getLong(9));
        g1.a(cursor.getLong(0));
        g1.a("f".equals(cursor.getString(11)));
        if(cursor != null)
            cursor.close();
        continue; /* Loop/switch isn't completed */
        if(cursor != null)
            cursor.close();
        if(true) goto _L1; else goto _L3
_L3:
        Exception exception;
        exception;
        if(cursor != null)
            cursor.close();
        throw exception;
    }

    private static String a(String s, long l1)
    {
        if(l1 > 0L)
        {
            String s1;
            if(TextUtils.isEmpty(s))
                s1 = "";
            else
                s1 = (new StringBuilder()).append(s).append(" AND ").toString();
            s = (new StringBuilder()).append(s1).append("timestamp < ").append(l1).toString();
        }
        return s;
    }

    public static void a(Context context, long l1)
    {
        if(context != null)
        {
            String s = a("data1 <> 'f'", l1);
            context.getContentResolver().delete(a.b, s, null);
        }
    }

    public static void a(Context context, String s)
    {
        a(context, -1L);
    }

    public static void a(Context context, String s, cls_g g1)
    {
        if(context != null && s != null)
        {
            ContentValues contentvalues = new ContentValues();
            if(g1.c())
                contentvalues.put("data1", "f");
            contentvalues.put("filepath", g1.e());
            contentvalues.put("timestamp", Long.valueOf(System.currentTimeMillis()));
            ContentResolver contentresolver = context.getContentResolver();
            android.net.Uri uri = a.b;
            String as[] = new String[1];
            as[0] = s;
            contentresolver.update(uri, contentvalues, "url =?", as);
        }
    }

    public static void a(Context context, String s, String s1, cls_g g1)
    {
        if(s1 != null)
        {
            ContentValues contentvalues = new ContentValues();
            contentvalues.put("account", s);
            contentvalues.put("url", s1);
            contentvalues.put("lastmodify", g1.h());
            contentvalues.put("filepath", g1.e());
            contentvalues.put("expiresstring", g1.g());
            contentvalues.put("expires", Long.valueOf(g1.f()));
            contentvalues.put("etag", g1.i());
            contentvalues.put("encoding", g1.j());
            contentvalues.put("contentlength", Long.valueOf(g1.d()));
            String s2;
            if(g1.c())
                s2 = "f";
            else
                s2 = "";
            contentvalues.put("data1", s2);
            context.getContentResolver().insert(a.b, contentvalues);
        }
    }

    public static void b(Context context, long l1)
    {
        if(context != null)
        {
            String s = a("data1 = 'f'", l1);
            context.getContentResolver().delete(a.b, s, null);
        }
    }

    public static void b(Context context, String s)
    {
        b(context, -1L);
    }

    public static void b(Context context, String s, cls_g g1)
    {
        if(g1 == null || g1.a() < 0L)
        {
            StringBuilder stringbuilder = (new StringBuilder()).append("");
            String s1;
            if(g1 != null)
                s1 = g1.e();
            else
                s1 = "";
            com.nnee.p_g.cls_b.d("delete cache", stringbuilder.append(s1).toString());
        } else
        {
            context.getContentResolver().delete(ContentUris.withAppendedId(a.b, g1.a()), "", null);
        }
    }

    public static long c(Context context, long l1)
    {
        long l2;
        if(context != null)
        {
            String s = a("data1 <> 'f'", l1);
            l2 = a(context, q, s);
        } else
        {
            l2 = 0L;
        }
        return l2;
    }

    public static long d(Context context, long l1)
    {
        long l2;
        if(context != null)
        {
            String s = a("data1 = 'f'", l1);
            l2 = a(context, q, s);
        } else
        {
            l2 = 0L;
        }
        return l2;
    }

    public static long e(Context context, long l1)
    {
        long l2;
        if(context != null)
        {
            String s = a("data1 <> 'f'", l1);
            l2 = a(context, r, s);
        } else
        {
            l2 = 0L;
        }
        return l2;
    }

    public static long f(Context context, long l1)
    {
        long l2;
        if(context != null)
        {
            String s = a("data1 = 'f'", l1);
            l2 = a(context, r, s);
        } else
        {
            l2 = 0L;
        }
        return l2;
    }

    public static String a[];
    public static final int b = 0;
    public static final int c = 1;
    public static final int d = 2;
    public static final int e = 3;
    public static final int f = 4;
    public static final int g = 5;
    public static final int h = 6;
    public static final int i = 7;
    public static final int j = 8;
    public static final int k = 9;
    public static final int l = 10;
    public static final int m = 11;
    private static final String n = "f";
    private static final String o = "data1 = 'f'";
    private static final String p = "data1 <> 'f'";
    private static String q[];
    private static String r[];

    static 
    {
        String as[] = new String[12];
        as[0] = "_id";
        as[1] = "account";
        as[2] = "url";
        as[3] = "lastmodify";
        as[4] = "filepath";
        as[5] = "expiresstring";
        as[6] = "expires";
        as[7] = "etag";
        as[8] = "encoding";
        as[9] = "contentlength";
        as[10] = "timestamp";
        as[11] = "data1";
        a = as;
        String as1[] = new String[1];
        as1[0] = "COUNT(*)";
        q = as1;
        String as2[] = new String[1];
        as2[0] = "SUM(contentlength)";
        r = as2;
    }
}
